#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPainter>
#include <QLabel>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    int centerX;
    int centerY;
    int Rleft = 375;
    int Rright;
    int Rtop = 212;
    int Rbottom;
    int speed;
    int adm = 0;//玩家
    int opp = 0;//电脑
    int kic = 0;//轮数
    int spt = 0;
    int turn = 0;
    int admtime = 5;
    int opptime = 5;
    QRect goalkeeperRect;
    QRect redAreaRect;
    QRect redOppRect;
    QLabel *admScoreLabel;
    QLabel *oppScoreLabel;
    QLabel *turnScoreLabel;
    QLabel *AttLabel;
    QLabel *DefLabel;
protected:
    void paintEvent(QPaintEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;
    void updateRedAreaPosition();
    void generateGoalkeeperPosition();
    double calculateOverlapArea(const QRect &rect1, const QRect &rect2);
    double calculateArea(const QRect &rect1, const QRect &rect2);
    void createScoreBox();
    void updateScore();
    bool victory();
    void gameLoop();
    void generateRedArea();
};
#endif // MAINWINDOW_H
